| 0.9.9 API documentation

- Main Page
- Modules
- Files

- File List

type_vec2.hpp
Go to the documentation of this file.
1
4 #pragma once
5
6 #include "qualifier.hpp"
7 #if GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR
8 # include "_swizzle.hpp"
9 #elif GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_FUNCTION
10 # include "_swizzle_func.hpp"
11 #endif
12 #include <cstddef>
13
14 namespace glm
15 {
16 template<typename T, qualifier Q>
17 struct vec<2, T, Q>
18 {
19 // -- Implementation detail --
20
21 typedef T value_type;
22 typedef vec<2, T, Q> type;
23 typedef vec<2, bool, Q> bool_type;
24
25 // -- Data --
26
27 # if GLM_SILENT_WARNINGS == GLM_ENABLE
28 # if GLM_COMPILER & GLM_COMPILER_GCC
29 # pragma GCC diagnostic push
30 # pragma GCC diagnostic ignored "-Wpedantic"
31 # elif GLM_COMPILER & GLM_COMPILER_CLANG
32 # pragma clang diagnostic push
33 # pragma clang diagnostic ignored "-Wgnu-anonymous-struct"
34 # pragma clang diagnostic ignored "-Wnested-anon-types"
35 # elif GLM_COMPILER & GLM_COMPILER_VC
36 # pragma warning(push)
37 # pragma warning(disable: 4201) // nonstandard extension used : nameless struct/union
38 # endif
39 # endif
40
41 # if GLM_CONFIG_XYZW_ONLY
42 T x, y;
43 # elif GLM_CONFIG_ANONYMOUS_STRUCT == GLM_ENABLE
44 union
45 {
46 struct{ T x, y; };
47 struct{ T r, g; };
48 struct{ T s, t; };
49
50 typename detail::storage<2, T, detail::is_aligned<Q>::value>::type data;
51
52 # if GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR
53 GLM_SWIZZLE2_2_MEMBERS(T, Q, x, y)
54 GLM_SWIZZLE2_2_MEMBERS(T, Q, r, g)
55 GLM_SWIZZLE2_2_MEMBERS(T, Q, s, t)
56 GLM_SWIZZLE2_3_MEMBERS(T, Q, x, y)
57 GLM_SWIZZLE2_3_MEMBERS(T, Q, r, g)
58 GLM_SWIZZLE2_3_MEMBERS(T, Q, s, t)
59 GLM_SWIZZLE2_4_MEMBERS(T, Q, x, y)
60 GLM_SWIZZLE2_4_MEMBERS(T, Q, r, g)
61 GLM_SWIZZLE2_4_MEMBERS(T, Q, s, t)
62 # endif
63 };
64 # else
65 union {T x, r, s;};
66 union {T y, g, t;};
67
68 # if GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_FUNCTION
69 GLM_SWIZZLE_GEN_VEC_FROM_VEC2(T, Q)
70 # endif//GLM_CONFIG_SWIZZLE
71 # endif
72
73 # if GLM_SILENT_WARNINGS == GLM_ENABLE
74 # if GLM_COMPILER & GLM_COMPILER_CLANG
75 # pragma clang diagnostic pop
76 # elif GLM_COMPILER & GLM_COMPILER_GCC
77 # pragma GCC diagnostic pop
78 # elif GLM_COMPILER & GLM_COMPILER_VC
79 # pragma warning(pop)
80 # endif
81 # endif
82
83 // -- Component accesses --
84
86 typedef length_t length_type;
87 GLM_FUNC_DECL static GLM_CONSTEXPR length_type length(){return 2;}
88
89 GLM_FUNC_DECL GLM_CONSTEXPR T& operator[](length_type i);
90 GLM_FUNC_DECL GLM_CONSTEXPR T const& operator[](length_type i) const;
91
92 // -- Implicit basic constructors --
93
94 GLM_FUNC_DECL GLM_CONSTEXPR vec() GLM_DEFAULT;
95 GLM_FUNC_DECL GLM_CONSTEXPR vec(vec const& v) GLM_DEFAULT;
96 template<qualifier P>
97 GLM_FUNC_DECL GLM_CONSTEXPR vec(vec<2, T, P> const& v);
98
99 // -- Explicit basic constructors --
100
101 GLM_FUNC_DECL GLM_CONSTEXPR explicit vec(T scalar);
102 GLM_FUNC_DECL GLM_CONSTEXPR vec(T x, T y);
103
104 // -- Conversion constructors --
105
106 template<typename U, qualifier P>
107 GLM_FUNC_DECL GLM_CONSTEXPR explicit vec(vec<1, U, P> const& v);
108
110 template<typename A, typename B>
111 GLM_FUNC_DECL GLM_CONSTEXPR vec(A x, B y);
112 template<typename A, typename B>
113 GLM_FUNC_DECL GLM_CONSTEXPR vec(vec<1, A, Q> const& x, B y);
114 template<typename A, typename B>
115 GLM_FUNC_DECL GLM_CONSTEXPR vec(A x, vec<1, B, Q> const& y);
116 template<typename A, typename B>
117 GLM_FUNC_DECL GLM_CONSTEXPR vec(vec<1, A, Q> const& x, vec<1, B, Q> const& y);
118
119 // -- Conversion vector constructors --
120
122 template<typename U, qualifier P>
123 GLM_FUNC_DECL GLM_CONSTEXPR GLM_EXPLICIT vec(vec<3, U, P> const& v);
125 template<typename U, qualifier P>
126 GLM_FUNC_DECL GLM_CONSTEXPR GLM_EXPLICIT vec(vec<4, U, P> const& v);
127
129 template<typename U, qualifier P>
130 GLM_FUNC_DECL GLM_CONSTEXPR GLM_EXPLICIT vec(vec<2, U, P> const& v);
131
132 // -- Swizzle constructors --
133 # if GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR
134 template<int E0, int E1>
135 GLM_FUNC_DECL GLM_CONSTEXPR vec(detail::_swizzle<2, T, Q, E0, E1,-1,-2> const& that)
136 {
137 *this = that();
138 }
139 # endif//GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR
140
141 // -- Unary arithmetic operators --
142
143 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> & operator=(vec const& v) GLM_DEFAULT;
144
145 template<typename U>
146 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> & operator=(vec<2, U, Q> const& v);
147 template<typename U>
148 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> & operator+=(U scalar);
149 template<typename U>
150 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> & operator+=(vec<1, U, Q> const& v);
151 template<typename U>
152 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> & operator+=(vec<2, U, Q> const& v);
153 template<typename U>
154 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> & operator-=(U scalar);
155 template<typename U>
156 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> & operator-=(vec<1, U, Q> const& v);
157 template<typename U>
158 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> & operator-=(vec<2, U, Q> const& v);
159 template<typename U>
160 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> & operator*=(U scalar);
161 template<typename U>
162 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> & operator*=(vec<1, U, Q> const& v);
163 template<typename U>
164 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> & operator*=(vec<2, U, Q> const& v);
165 template<typename U>
166 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> & operator/=(U scalar);
167 template<typename U>
168 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> & operator/=(vec<1, U, Q> const& v);
169 template<typename U>
170 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> & operator/=(vec<2, U, Q> const& v);
171
172 // -- Increment and decrement operators --
173
174 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> & operator++();
175 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> & operator--();
176 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator++(int);
177 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator--(int);
178
179 // -- Unary bit operators --
180
181 template<typename U>
182 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> & operator%=(U scalar);
183 template<typename U>
184 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> & operator%=(vec<1, U, Q> const& v);
185 template<typename U>
186 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> & operator%=(vec<2, U, Q> const& v);
187 template<typename U>
188 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> & operator&=(U scalar);
189 template<typename U>
190 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> & operator&=(vec<1, U, Q> const& v);
191 template<typename U>
192 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> & operator&=(vec<2, U, Q> const& v);
193 template<typename U>
194 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> & operator|=(U scalar);
195 template<typename U>
196 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> & operator|=(vec<1, U, Q> const& v);
197 template<typename U>
198 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> & operator|=(vec<2, U, Q> const& v);
199 template<typename U>
200 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> & operator^=(U scalar);
201 template<typename U>
202 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> & operator^=(vec<1, U, Q> const& v);
203 template<typename U>
204 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> & operator^=(vec<2, U, Q> const& v);
205 template<typename U>
206 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> & operator<<=(U scalar);
207 template<typename U>
208 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> & operator<<=(vec<1, U, Q> const& v);
209 template<typename U>
210 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> & operator<<=(vec<2, U, Q> const& v);
211 template<typename U>
212 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> & operator>>=(U scalar);
213 template<typename U>
214 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> & operator>>=(vec<1, U, Q> const& v);
215 template<typename U>
216 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> & operator>>=(vec<2, U, Q> const& v);
217 };
218
219 // -- Unary operators --
220
221 template<typename T, qualifier Q>
222 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator+(vec<2, T, Q> const& v);
223
224 template<typename T, qualifier Q>
225 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator-(vec<2, T, Q> const& v);
226
227 // -- Binary operators --
228
229 template<typename T, qualifier Q>
230 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator+(vec<2, T, Q> const& v, T scalar);
231
232 template<typename T, qualifier Q>
233 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator+(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2);
234
235 template<typename T, qualifier Q>
236 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator+(T scalar, vec<2, T, Q> const& v);
237
238 template<typename T, qualifier Q>
239 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator+(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2);
240
241 template<typename T, qualifier Q>
242 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator+(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2);
243
244 template<typename T, qualifier Q>
245 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator-(vec<2, T, Q> const& v, T scalar);
246
247 template<typename T, qualifier Q>
248 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator-(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2);
249
250 template<typename T, qualifier Q>
251 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator-(T scalar, vec<2, T, Q> const& v);
252
253 template<typename T, qualifier Q>
254 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator-(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2);
255
256 template<typename T, qualifier Q>
257 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator-(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2);
258
259 template<typename T, qualifier Q>
260 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator*(vec<2, T, Q> const& v, T scalar);
261
262 template<typename T, qualifier Q>
263 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator*(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2);
264
265 template<typename T, qualifier Q>
266 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator*(T scalar, vec<2, T, Q> const& v);
267
268 template<typename T, qualifier Q>
269 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator*(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2);
270
271 template<typename T, qualifier Q>
272 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator*(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2);
273
274 template<typename T, qualifier Q>
275 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator/(vec<2, T, Q> const& v, T scalar);
276
277 template<typename T, qualifier Q>
278 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator/(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2);
279
280 template<typename T, qualifier Q>
281 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator/(T scalar, vec<2, T, Q> const& v);
282
283 template<typename T, qualifier Q>
284 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator/(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2);
285
286 template<typename T, qualifier Q>
287 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator/(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2);
288
289 template<typename T, qualifier Q>
290 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator%(vec<2, T, Q> const& v, T scalar);
291
292 template<typename T, qualifier Q>
293 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator%(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2);
294
295 template<typename T, qualifier Q>
296 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator%(T scalar, vec<2, T, Q> const& v);
297
298 template<typename T, qualifier Q>
299 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator%(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2);
300
301 template<typename T, qualifier Q>
302 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator%(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2);
303
304 template<typename T, qualifier Q>
305 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator&(vec<2, T, Q> const& v, T scalar);
306
307 template<typename T, qualifier Q>
308 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator&(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2);
309
310 template<typename T, qualifier Q>
311 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator&(T scalar, vec<2, T, Q> const& v);
312
313 template<typename T, qualifier Q>
314 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator&(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2);
315
316 template<typename T, qualifier Q>
317 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator&(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2);
318
319 template<typename T, qualifier Q>
320 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator|(vec<2, T, Q> const& v, T scalar);
321
322 template<typename T, qualifier Q>
323 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator|(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2);
324
325 template<typename T, qualifier Q>
326 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator|(T scalar, vec<2, T, Q> const& v);
327
328 template<typename T, qualifier Q>
329 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator|(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2);
330
331 template<typename T, qualifier Q>
332 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator|(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2);
333
334 template<typename T, qualifier Q>
335 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator^(vec<2, T, Q> const& v, T scalar);
336
337 template<typename T, qualifier Q>
338 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator^(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2);
339
340 template<typename T, qualifier Q>
341 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator^(T scalar, vec<2, T, Q> const& v);
342
343 template<typename T, qualifier Q>
344 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator^(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2);
345
346 template<typename T, qualifier Q>
347 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator^(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2);
348
349 template<typename T, qualifier Q>
350 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator<<(vec<2, T, Q> const& v, T scalar);
351
352 template<typename T, qualifier Q>
353 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator<<(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2);
354
355 template<typename T, qualifier Q>
356 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator<<(T scalar, vec<2, T, Q> const& v);
357
358 template<typename T, qualifier Q>
359 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator<<(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2);
360
361 template<typename T, qualifier Q>
362 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator<<(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2);
363
364 template<typename T, qualifier Q>
365 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator>>(vec<2, T, Q> const& v, T scalar);
366
367 template<typename T, qualifier Q>
368 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator>>(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2);
369
370 template<typename T, qualifier Q>
371 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator>>(T scalar, vec<2, T, Q> const& v);
372
373 template<typename T, qualifier Q>
374 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator>>(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2);
375
376 template<typename T, qualifier Q>
377 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator>>(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2);
378
379 template<typename T, qualifier Q>
380 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator~(vec<2, T, Q> const& v);
381
382 // -- Boolean operators --
383
384 template<typename T, qualifier Q>
385 GLM_FUNC_DECL GLM_CONSTEXPR bool operator==(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2);
386
387 template<typename T, qualifier Q>
388 GLM_FUNC_DECL GLM_CONSTEXPR bool operator!=(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2);
389
390 template<qualifier Q>
391 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, bool, Q> operator&&(vec<2, bool, Q> const& v1, vec<2, bool, Q> const& v2);
392
393 template<qualifier Q>
394 GLM_FUNC_DECL GLM_CONSTEXPR vec<2, bool, Q> operator||(vec<2, bool, Q> const& v1, vec<2, bool, Q> const& v2);
395 }//namespace glm
396
397 #ifndef GLM_EXTERNAL_TEMPLATE
398 #include "type_vec2.inl"
399 #endif//GLM_EXTERNAL_TEMPLATE
glm::length
GLM_FUNC_DECL T length(qua< T, Q > const &q)
Returns the norm of a quaternions.
glm
Definition: common.hpp:20